package com.example.sunmiv1.utils

import android.widget.EditText
import android.widget.TextView
import com.example.sunmiv1.entity.GoodBean

object KotlinUtils {
    fun getGoodItemIndex(list:List<GoodBean.DataBean>,item:GoodBean.DataBean.GoodsBean):ArrayList<Int>{
        val resultList= arrayListOf<Int>()
        list.forEachIndexed { index, dataBean ->
            dataBean.goods?.forEachIndexed { childIndex, goodsBean ->
                if(goodsBean.id==item.id){
                    resultList.add(index)
                    resultList.add(childIndex)
                    return resultList
                }
            }
        }
        resultList.add(-1)
        resultList.add(-1)
        return resultList
    }
    fun getEditNumber(edit:EditText):Double{
        return edit.editableText.trim().toString().toDoubleOrNull()?:0.00
    }
    fun getTextNumber(edit:TextView):Double{
        return edit.text.trim().toString().toDoubleOrNull()?:0.00
    }
    fun isTextBlank(edit:TextView):Boolean{
        return edit.text.isBlank()
    }
    fun isTextNotBlank(edit:TextView):Boolean{
        return edit.text.isNotBlank()
    }
}